<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <% String path = request.getContextPath();%>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="<%=path%>/layui/css/layui.css">
    <script src="<%=path%>/layui/layui.js" type="text/javascript"></script>
    <script src="<%=path%>/jquery-3.4.1.js"></script>
</head>

<body onload="init();">
<div class="layui-container">
    <div class="layui-row">
        <form class="layui-form" style="margin-top: 8%;">
            <div class="layui-form-item">
                <label class="layui-form-label">实验室名称</label>
                <div class="layui-input-block">
                    <input type="text" name="labName" id="input_labName" disabled="disabled" placeholder="实验室名称" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">实验室容量</label>
                <div class="layui-input-block">
                    <input type="text" name="labCapa" id="input_labTotal" disabled="disabled" placeholder="实验室容量" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">实验室类型</label>
                <div class="layui-input-block">
                    <input type="text" name="labType" id="input_labTag" disabled="disabled" placeholder="实验室类型" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item" style="margin-top: 6%;  margin-left: 13%;">
                <div class="layui-input-block">
                    <button id="btn" class="layui-btn layui-btn-normal" onclick="know()">我知道了</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script src="<%=path%>/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    function know() {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }
</script>
<script type="text/javascript">
    function init() {
        let parent_json = eval('('+parent.json+')');
        $.ajax({
            type:"POST"
            ,url:"${pageContext.request.contextPath}/jsp/user.do?method=getLabDataByLabName&labName="+parent_json.labName
            ,dataType: "json"
            ,success:function (data) {
                $('#input_labName').val(parent_json.labName);
                $('#input_labTotal').val(data.labData.labTotal);
                if (data.labData.labTag === 0){
                    $('#input_labTag').val("普通");
                }else{
                    $('#input_labTag').val("专业");
                }
            }
            ,error:function () {
                $('#input_labName').val("数据获取失败");
            }
        });
    }
</script>
</body>

</html>
